﻿using M_Manufacture.API.Application.Command.WorkOrderCommand;
using M_Manufacture.Repository.Interface;
using MediatR;

namespace M_Manufacture.API.Application.CommandHandlers.WorkOrderCommandHandler
{
    /// <summary>
    /// 工单下发
    /// </summary>
    public class XiaFaWorkOrderCommandHandler : IRequestHandler<XiaFaWorkOrderCommand, int>
    {
        private readonly IWorkOrderRepository _workOrderRepository;
        public XiaFaWorkOrderCommandHandler(IWorkOrderRepository workOrderRepository)
        {
            _workOrderRepository = workOrderRepository;
        }
        public async Task<int> Handle(XiaFaWorkOrderCommand request, CancellationToken cancellationToken)
        {
            var ss = await _workOrderRepository.GetModelsAsync(request.WorkOrderId);
            ss.WorkOrderSart = "待生产";
            ss.SingleNumber=request.SingleNumber;
            return await _workOrderRepository.UpdateAsync(ss);
        }
    }
}
